home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / printing / prtinstl.lzh / prtinst.s < prev    next >
Text File  |  1986-11-22  |  7KB  |  186 lines

  1. ;
  2. ;   PRTINST.S
  3. ;
  4. ;   Installs a DEGAS print driver as system screen dump driver
  5. ;   Loads from \AUTO folder of boot disk
  6. ;
  7. ;   Russ Wetmore
  8. ;   Converted to ASSEMPRO format: 11/18/86
  9. ;   Last revision: 11/20/86
  10. ;
  11.  
  12.         Include tos\gemdos.s
  13.         Include tos\bios.s
  14.         Include tos\xbios.s
  15.  
  16. ;-------------------------------;
  17. ;   global equates              ;
  18. ;-------------------------------;
  19. CR = 13
  20. LF = 10
  21. scrndump = $0502
  22.  
  23. ;===================================================================;
  24.         Text
  25. ;===================================================================;
  26.  
  27. ;-------------------------------;
  28. start:                          ;   Start here, install & stay resident
  29. ;-------------------------------;
  30.         Move.L      4(SP),A0            ; A0 => base page
  31.         Move.L      $C(A0),D3           ; TEXT segment size...
  32.         Add.L       $14(A0),D3          ; ...plus DATA segment size
  33.         Add.L       $1C(A0),D3          ; ...plus BSS segment size
  34.         Add.L       #256,D3             ; ...plus base page size
  35.                                         ; ...is size of whole program
  36.  
  37.         PRINTLINE   whoweare            ; Clue Butch in on who we are
  38.  
  39.         OPEN        #0,filename         ; Open file
  40.         Bpl.S       openok
  41.  
  42.         Cmp         #-33,D0             ; File not found?
  43.         Bne.S       notfnf
  44.  
  45.         PRINTLINE   cantfind            ; Tell Butch we no can find
  46.         PRINTLINE   filename
  47.         PRINTLINE   crlf
  48.         Bra.S       nosave
  49.  
  50. notfnf:
  51.         PRINTLINE   fileerror           ; Tell Butch something's wrong
  52. nosave:
  53.         TERM
  54.  
  55. openok:
  56.         Move        D0,D4
  57.         READ        routine,#2000,D4    ; Read in 2000 bytes
  58.  
  59.         Move.L      D0,-(SP)            ; Save number of bytes read
  60.         CLOSE       D4
  61.         Move.L      (SP)+,D0
  62.  
  63.         Bmi.S       notfnf              ; Negative means error!
  64.  
  65.         SUPEXEC     install             ; Point GEMDOS at our routine
  66.  
  67.         PRINTLINE   filename            ; Tell Butch all's right with
  68.         PRINTLINE   success             ; ...the world
  69.  
  70.         KEEPPROC    #0,D3               ; Save whole program & exit
  71.  
  72.         Nop                             ; Never comes back, but sometimes
  73.                                         ; next word gets munged!
  74.  
  75. ;-------------------------------;
  76. install:                        ;   Must be executed in supervisor mode!
  77. ;-------------------------------;
  78.         Lea         dumper,A0           ; Point at routine
  79.         Move.L      A0,scrndump         ; Stuff GEMDOS' vector
  80.         Rts
  81.  
  82.  
  83. ;-------------------------------;
  84. dumper:                         ;   Sets up and calls DEGAS driver
  85. ;-------------------------------;
  86.         MoveM.L     D0-D7/A0-A6,-(SP)
  87.  
  88.         GETREZ                          ; Fetch resolution
  89.         Move        D0,D3
  90.  
  91.         PHYSBASE                        ; Fetch pointer to screen base
  92.         Move.L      D0,D4
  93.  
  94.         Lea         palette,A3          ; Point at palette
  95.         Move        #15,D5              ; Count is 15 to 0
  96.         Move        #30,D6
  97. palloop:
  98.         SETCOLOR    #-1,D5              ; Fetch color
  99.         Move        D0,0(A3,D6.W)       ; Save in palette
  100.         SubQ        #2,D6
  101.         Dbra        D5,palloop
  102.  
  103.         Cmp         #2,D3               ; If high resolution...
  104.         Bne.S       nothigh
  105.  
  106.         Move        (A3),D0             ; Fetch color0
  107.         And         #1,D0
  108.         Beq.S       isblack
  109.  
  110.         Move.L      #$07770000,(A3)     ; Color0=white, color1=black
  111.         Bra.S       nothigh
  112.  
  113. isblack:
  114.         Move.L      #$00000777,(A3)     ; Color0=black, color1=white
  115.  
  116. nothigh:
  117.         KBSHIFT     #-1                 ; See if SHIFT key is down
  118.         And         #%00000111,D0       ; (...or CONTROL key...)
  119.         Sne         D0                  ; Mask bit 3 in if down, so
  120.         And         #%00001000,D0       ; ...Kbshift will simulate ALT
  121.  
  122. ; At this point, D3=rez, D4=>screen, A3=>palette, & D0=Kbshift value
  123.         KBSHIFT     D0
  124.  
  125.         Pea         workarea            ; 1280 byte scratch space
  126.         Move.L      A3,-(SP)            ; Palette address
  127.         Move.L      D4,-(SP)            ; Screen data base address
  128.         Move        D3,-(SP)            ; Resolution
  129.         Clr         -(SP)               ; Initialize printer command
  130.         Bsr         routine             ; Call driver
  131.         Lea         16(SP),SP           ; Fix stack anomoly
  132.  
  133.         Cmp         #0,D0               ; If init went okay
  134.         Beq.S       dontprint
  135.  
  136.         Pea         workarea            ; 1280 byte scratch space
  137.         Move.L      A3,-(SP)            ; Palette address
  138.         Move.L      D4,-(SP)            ; Screen data base address
  139.         Move        D3,-(SP)            ; Resolution
  140.         Move        #1,-(SP)            ; Print command
  141.         Bsr         routine             ; Call driver
  142.         Lea         16(SP),SP           ; Fix stack anomoly
  143.  
  144. dontprint:
  145.         KBSHIFT     #0                  ; Fix ALT key if necessary
  146.  
  147.         MoveM.L     (SP)+,D0-D7/A0-A6
  148.         Rts
  149.  
  150. ;===================================================================;
  151.         Data
  152. ;===================================================================;
  153. filename:                               ; Name of DEGAS print driver
  154.         Dc.B        "A:\DEGAS.PRT",0,0,0,0
  155.         Ds.B        16,0                ; 16 extra for futzing
  156.  
  157. success:                                ; Let's party!
  158.         Dc.B        " successfully loaded."
  159.  
  160. crlf:                                   ; Carriage return/line feed
  161.         Dc.B        CR,LF,0
  162.  
  163. cantfind:                               ; Uh, where is it?
  164.         Dc.B        "Error!  Can't find "
  165.  
  166. fileerror:                              ; Some kind of file error...
  167.         Dc.B        "Unexpected file error!",CR,LF,0
  168.  
  169. whoweare:                               ; Blatant vanity
  170.         Dc.B        CR,LF,"DEGAS .PRT file loader",CR,LF
  171.         Dc.B        "  by Russ Wetmore",CR,LF,0
  172.  
  173. ;===================================================================;
  174.         Bss
  175. ;===================================================================;
  176. routine:                                ; Where driver will be stored
  177.         Ds.B        2000
  178.  
  179. workarea:                               ; DEGAS' scratch data area
  180.         Ds.B        1280
  181.  
  182. palette:                                ; Where palette will be stored
  183.         Ds.W        16
  184.  
  185.         End